home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 …ember: Reference Library / Dev.CD Dec 00 RL Disk 1.toast / pc / technical documentation / develop / develop issue 27 / develop issue 27 code / internet config assistant / toolkit / cwindows.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-06-30  |  3.7 KB  |  180 lines

  1. /*
  2.     File:        CWindows.h
  3.  
  4.     Contains:    Layer built on top of the Window Manager
  5.  
  6.     Written by:    Arno Gourdol
  7.  
  8.     Copyright:    © 1994-1995 by Apple Computer, Inc., all rights reserved.
  9.  
  10. */
  11.  
  12. #pragma once
  13.  
  14. #ifndef __CWINDOWS__
  15. #define __CWINDOWS__
  16.  
  17. #include <Windows.h>
  18. #include "TDrawContext.h"
  19.  
  20. enum
  21. {
  22.     keyHome = 0x01,
  23.     keyEnter = 0x03,
  24.     keyEnd = 0x04,
  25.     keyHelp = 0x05,
  26.     keyArrowLeft = 0x1C,
  27.     keyArrowRight = 0x1D,
  28.     keyArrowUp = 0x1E,
  29.     keyArrowDown = 0x1F,
  30.     keyBackspace = 0x08,
  31.     keyTab = 0x09,
  32.     keyLineFeed = 0x0A,
  33.     keyPageUp = 0x0B,
  34.     keyPageDown = 0x0C,
  35.     keyReturn = 0x0D,
  36.     keySpace = 0x20,
  37.     keyF1 = 0x7A00,
  38.     keyF2 = 0x7800,
  39.     keyF3 = 0x6300,
  40.     keyF4 = 0x7600,
  41.     keyUndo = keyF1,
  42.     keyCut = keyF2,
  43.     keyCopy = keyF3,
  44.     keyPaste = keyF4,
  45.     keyF5 = 0x6000,
  46.     keyF6 = 0x6100,
  47.     keyF7 = 0x6200,
  48.     keyF8 = 0x6400,
  49.     keyF9 = 0x6500,
  50.     keyF10 = 0x6D00,
  51.     keyF11 = 0x6700,
  52.     keyF12 = 0x6F00,
  53.     keyF13 = 0x6900,
  54.     keyF14 = 0x6B00,
  55.     keyF15 = 0x7100,
  56.     keyFwdDel = 0x7500,
  57.     keyClear = 0x1B,
  58.     keyEscape = 0x11B
  59. };
  60.  
  61. class CWindow
  62. {
  63.     enum
  64.     {
  65.         kModelessWindow = 1,
  66.         kApplicationModalWindow = 2,
  67.         kSystemModalWindow = 4
  68.     };
  69. public:
  70.     // constructor
  71.     CWindow(UInt16 windowType = kModelessWindow);
  72.         
  73.     // destructor
  74.     virtual ~CWindow();        
  75.  
  76.     // closing
  77.     virtual void Close(void);
  78.     virtual Boolean CloseRequested(void);
  79.     
  80.     // Menus
  81.     virtual void MenusWillShow(void);
  82.     
  83.     // events
  84.     virtual Boolean FilterEvent(const EventRecord &event);
  85.     virtual void WindowActivated(Boolean active);
  86.     virtual void MouseDown(const EventRecord& event);    
  87.     virtual Boolean FilterKey(const EventRecord& event, UInt16 key);    
  88.     virtual void Pulse(void);
  89.     void ResizeBy(GraphicalUnit dx, GraphicalUnit dy);
  90.     void ResizeTo(GraphicalUnit width, GraphicalUnit height);
  91.     void Zoom(Boolean zoomOut = false);
  92.     
  93.     // others
  94.     virtual WindowRef MakeWindow(void);
  95.     inline void CreateWindow(void);
  96.  
  97.     void MoveTo(const CPoint& location);
  98.     virtual void FrameResized(GraphicalUnit newWidth, GraphicalUnit newHeight);
  99.     virtual    void FrameMoved(const CPoint& newLocation);
  100.  
  101.     // screen management
  102.     virtual void Show(void);
  103.     virtual void Hide(void);
  104.     GDHandle GetMaxIntersectedDevice(class CRect& screenRect);
  105.     virtual void ForceOnScreen(void);
  106.     void DoUpdate(RgnHandle area);
  107.     virtual void Draw(TDrawContext& drawContext) = 0;
  108.     void DrawGrowIcon(TDrawContext& drawContext) const;
  109.     void SetSizeLimits(    GraphicalUnit minH, GraphicalUnit maxH,
  110.                         GraphicalUnit minV, GraphicalUnit maxV);
  111.  
  112.     // selectors
  113.     inline WindowRef GetWindowRef(void) const;        
  114.     inline UInt16 GetWindowType(void) const;        
  115.     inline GrafPtr GetGrafPtr(void) const;
  116.     inline CRect Bounds(void) const;
  117.     
  118.     // Windows iteration
  119.     static CWindow* GetCWindow(WindowRef window);
  120.     inline static CWindow* GetFirstWindow(void) { return gWindowList; };
  121.     inline CWindow* GetNextWindow(void) const;
  122.     inline void SetNextWindow(CWindow* window);
  123.  
  124. protected:
  125.     WindowRef fWindow;
  126.     UInt16 fWindowType;
  127.     
  128.     // User Interface
  129.     // ??? Add maximum and minimum size to the window
  130.     CRect fExtent;                                // Maximum size of the window
  131.  
  132. private:
  133.     // linked list of windows used to turn dialog pointers into CDialogs
  134.     static CWindow *gWindowList;
  135.     CWindow *fNextWindow;
  136.  
  137.     static pascal void DrawDispatch(short depth, short deviceFlags, GDHandle targetDevice, CWindow* window);
  138.  
  139. };
  140.  
  141.  
  142. inline void CWindow::CreateWindow(void)
  143. {
  144.     fWindow = MakeWindow();
  145. }
  146.  
  147. inline UInt16 CWindow::GetWindowType(void) const
  148. {
  149.     return fWindowType;
  150. }
  151.  
  152.  
  153. inline WindowRef CWindow::GetWindowRef(void) const
  154. {
  155.     return fWindow;
  156. }
  157.  
  158. inline GrafPtr CWindow::GetGrafPtr(void) const
  159. {
  160.     return (GrafPtr)::GetWindowPort(GetWindowRef());
  161. }
  162.  
  163. CRect CWindow::Bounds(void) const
  164. {
  165.     return TDrawContext(GetGrafPtr()).Bounds();
  166. }
  167.  
  168. CWindow *CWindow::GetNextWindow(void) const
  169. {
  170.     return fNextWindow;
  171. }
  172.  
  173.  
  174. void CWindow::SetNextWindow(CWindow *window)
  175. {
  176.     fNextWindow = window;
  177. }
  178.  
  179. #endif
  180.